package com.linkdood.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkdood.app.domain.AccountUploadFile;
import com.linkdood.app.mapper.AccountUploadFileMapper;
import com.linkdood.app.service.AccountUploadFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 文件关联账户
 */
@Service
@Slf4j
public class AccountUploadFileServiceImpl extends ServiceImpl<AccountUploadFileMapper, AccountUploadFile> implements AccountUploadFileService {

    /**
     * 新增
     */
    @Override
    public AccountUploadFile saveFileAccount(String fileId, String accountId) {
        if (StringUtils.isEmpty(fileId) || StringUtils.isEmpty(accountId)) {
            return null;
        }
        AccountUploadFile accountUploadFile = new AccountUploadFile();
        accountUploadFile.setAccountId(accountId);
        accountUploadFile.setFileId(fileId);
        save(accountUploadFile);
        return accountUploadFile;
    }

    @Override
    public void removeByFileId(String fileId) {
        lambdaUpdate().eq(AccountUploadFile::getFileId, fileId).remove();
    }
}
